package com.zzk.protect.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zzk.protect.common.CommonResult;
import com.zzk.protect.pojo.PatientExpense;
import com.zzk.protect.service.PatientExpenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/patientExpense")
public class PatientExpenseController {
    @Autowired
    private PatientExpenseService patientExpenseService;
    @GetMapping("/paymentType")
    public CommonResult<List<Integer>> paymentType(){
        List<PatientExpense> list = patientExpenseService.list();
        // 使用Stream API提取paymentType字段并收集为List
        List<Integer> payTypeList = list.stream()
                .map(PatientExpense::getPaymentType)
                .collect(Collectors.toList());

        // 返回统一封装的结果
        return CommonResult.success(payTypeList);
    }
}
